﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HZ.Supervise.Web.Common
{
    public partial class FindAllHospital1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            

            if (!IsPostBack)
            {
                
                dataBind();
            }
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        private void dataBind()
        {
            HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
            string where = "";
            string areaID = "";

            int i;

            if (!string.IsNullOrEmpty(this.txtHosName.Text))
            {
                where = DAL.DAL_Helper.Replace(this.txtHosName.Text.Trim());
            }
            if (!CurrentAccount.GetUser().Org.Area.AreaID.Equals(Constants.CURRENT_DEPLOY_AREAID))
            {
                areaID = CurrentAccount.GetUser().Org.Area.AreaID;
            }
            DataTable dt = pre.GetHospital(where, "X" + areaID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out i);
            AspNetPager1.RecordCount = i;
            gvwHosList.DataSource = dt;
            gvwHosList.DataBind();
        }

        /// <summary>
        /// 查询按钮
        /// by张雄  2011.5.8
        /// </summary>
        /// <param name="sender">事件发送源</param>
        /// <param name="e">参数</param>
        protected void btnQery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {

            dataBind();

        }

        protected void gvwHosList_DataBound(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", ""); 
        }
    }
}
